package me.zhengjie.controller;

import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.log.aop.WebLog;
import me.zhengjie.pojo.dto.DeliveryDto;
import me.zhengjie.pojo.dto.ThreeFloorOutboundDto;
import me.zhengjie.pojo.entity.StorageReleaseDto;
import me.zhengjie.pojo.entity.TaskWhetherExistDto;
import me.zhengjie.pojo.vo.ReturnVo;
import me.zhengjie.service.DeliveryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/delivery")
@RequiredArgsConstructor
public class DeliveryController {
    private static final Logger outbound = LoggerFactory.getLogger("wcsOutbound");

    private final DeliveryService deliveryService;

    //配送任务
    @PostMapping("/task")
    public ReturnVo deliveryTask(@RequestBody DeliveryDto oneFloorOutboundDto){
        outbound.info("WMS下发出库任务,请求参数：{}",oneFloorOutboundDto);
        ReturnVo returnVo = deliveryService.deliveryTask(oneFloorOutboundDto);
        return returnVo;
    }

    @GetMapping("/inbound/task")
    public ReturnVo inboundTask(){
        ReturnVo returnVo = deliveryService.inboundTask();
        return returnVo;
    }

    //3楼出库
    @PostMapping("/three/floor/outbound")
    @WebLog(description = "WMS下发3楼出库任务", logName = "wcsOutbound", category = "出库任务")
    public ReturnVo threeFloorOutbound(@RequestBody ThreeFloorOutboundDto threeFloorOutboundDto){
        outbound.info("WMS下发3楼出库任务,请求参数：{}",threeFloorOutboundDto);
        ReturnVo returnVo = deliveryService.threeFloorOutbound(threeFloorOutboundDto);
        return returnVo;
    }

    //wms人工入庫
    @ApiOperation("WMS人工入庫")
    @PostMapping("/artificial/inbound")
    @WebLog(description = "WCS人工入库", logName = "wcsInbound", category = "出库任务")
    public ReturnVo artificialInbound(@RequestBody DeliveryDto oneFloorOutboundDto){
        outbound.info("wms下发人工出库接口参数：{}",oneFloorOutboundDto);
        ReturnVo returnVo = deliveryService.artificialInbound(oneFloorOutboundDto);
        return returnVo;
    }

    //查询容器是否在任务中
    @PostMapping("/containerCode/task/Whether/exist")
    @WebLog(description = "WMS下发3楼出库任务", logName = "wcsOutbound", category = "出库任务")
    public ReturnVo containerCodeTaskWhetherExist(@RequestBody TaskWhetherExistDto taskWhetherExistDto){
        ReturnVo returnVo = deliveryService.containerCodeTaskWhetherExist(taskWhetherExistDto);
        return returnVo;
    }


    //WMS下发储位解绑
    @ApiOperation("WMS下发储位解绑")
    @PostMapping("/storage/release")
    public ReturnVo storageRelease(@RequestBody StorageReleaseDto storageReleaseDto){
        ReturnVo returnVo = deliveryService.storageRelease(storageReleaseDto);
        return returnVo;
    }
}
